home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / ldapurl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-10-08  |  3.6 KB  |  111 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2004 Szombathelyi Gy├╢rgy <gyurco@freemail.hu>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General  Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef _K_LDAPURL_H_
  22. #define _K_LDAPURL_H_
  23.  
  24. #include <qstring.h>
  25. #include <qstringlist.h>
  26. #include <qmap.h>
  27.  
  28. #include <kurl.h>
  29.  
  30. namespace KABC {
  31.  
  32. /**
  33.  * LDAPUrl
  34.  
  35.  * LDAPUrl implements an RFC 2255 compliant LDAP Url parser, with minimal
  36.  * differences. LDAP Urls implemented by this class has the following format:
  37.  * ldap[s]://[user[:password]@]hostname[:port]["/" [dn ["?" [attributes] 
  38.  * ["?" [scope] ["?" [filter] ["?" extensions]]]]]]
  39.  */
  40.  
  41.  
  42.   class KABC_EXPORT LDAPUrl : public KURL
  43.   {
  44.   public:
  45.  
  46.     struct Extension {
  47.       QString value;
  48.       bool critical;
  49.     };
  50.     
  51.     typedef enum Scope { Base, One, Sub };
  52.  
  53.     /** Constructs an empty KLDAPUrl. */
  54.     LDAPUrl();
  55.     /** Constructs a KLDAPUrl from a KURL. */
  56.     LDAPUrl( const KURL &url );
  57.   
  58.     /**
  59.      * Returns the dn part of the LDAP Url (same as path(), but slash removed
  60.      * from the beginning).
  61.      */
  62.     const QString& dn() const { return m_dn; }
  63.     /** Sets the the dn part of the LDAP Url. */ 
  64.     void setDn( const QString &dn );
  65.  
  66.     /** Returns the attributes part of the LDAP Url */
  67.     const QStringList &attributes() { return m_attributes; }
  68.     /** Sets the attributes part of the LDAP Url */
  69.     void setAttributes( const QStringList &attributes ) 
  70.       { m_attributes=attributes; updateQuery(); }
  71.  
  72.     /** Returns the scope part of the LDAP Url */
  73.     Scope scope() const { return m_scope; }
  74.     /** Sets the scope part of the LDAP Url */
  75.     void setScope(Scope scope) { m_scope = scope; updateQuery(); }
  76.  
  77.     /** Returns the filter part of the LDAP Url */
  78.     const QString &filter() const { return m_filter; }
  79.     /** Sets the filter part of the LDAP Url */
  80.     void setFilter( QString filter ) { m_filter = filter; updateQuery(); }
  81.  
  82.     /** Returns if the specified extension exists in the LDAP Url */
  83.     bool hasExtension( const QString &key ) const;
  84.     /** Returns the specified extension */
  85.     Extension extension( const QString &key ) const;
  86.     /** Returns the specified extension */
  87.     QString extension( const QString &key, bool &critical ) const;
  88.     /** Sets the specified extension key with the value and criticality in ext */
  89.     void setExtension( const QString &key, const Extension &ext );
  90.     /** Sets the specified extension key with the value and criticality specified */
  91.     void setExtension( const QString &key, const QString &value, bool critical = false );
  92.     /** Removes the specified extension */
  93.     void removeExtension( const QString &key );
  94.     /** Updates the query component from the attributes, scope, filter and extensions */
  95.     void updateQuery();
  96.     
  97.   protected:
  98.     void parseQuery();
  99.  
  100.   private:
  101.  
  102.     QMap<QString, Extension> m_extensions;
  103.     QString m_dn;
  104.     QStringList m_attributes;
  105.     Scope m_scope;
  106.     QString m_filter;
  107.   };
  108. }
  109.  
  110. #endif
  111.